package thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        Boo boo1 = new Boo();
        Boo boo2 = new Boo();
        Thread t1 = new Thread(){
            public void run(){
//                Boo.doSome();
                boo1.doSome();
            }
        };
        Thread t2 = new Thread(){
            public void run(){
//                Boo.doSome();
                boo2.doSome();
            }
        };
        t1.start();
        t2.start();





    }
}
class Boo{
//    public synchronized static void doSome(){
    public static void doSome(){
        synchronized (Boo.class){
            Thread t = Thread.currentThread();
            System.out.println(t + "执行开始");
            try {
                Thread.sleep(3000);
            }catch (InterruptedException e){
            }
            System.out.println(t + "执行完毕");
        }

    }
}
